﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Core;

namespace DAL
{
    public class ReExamDetailDAL : SyncBase<Model.ReExamDetail>
    {
        static ReExamDetailDAL()
        {
            StringBuilder strSql = new StringBuilder();
            ReExamDetailDAL.addSQL = @"insert into TempReExamDetail(
ExamID,LessionID,TeacherID,StudentID,TestID,StemID,Answer,AnswerResID,AnswerResUrl,IsCorrect,AnswerTime)
 values (
@ExamID,@LessionID,@TeacherID,@StudentID,@TestID,@StemID,@Answer,@AnswerResID,@AnswerResUrl,@IsCorrect,@AnswerTime)";
            ReExamDetailDAL.tbName = "TempReExamDetail";
            ReExamDetailDAL.remoteUrl = "/Ayyfford/AddReExamDetail";
            ReExamDetailDAL.setVal = (lt) =>
            {
                StringBuilder sb = new StringBuilder();
                string _ids = string.Empty;
                if (lt != null && lt.Count > 0)
                {
                    lt.ForEach(t =>
                    {
                        _ids += t.ID + ",";
                        sb.AppendFormat("({0}, {1}, {2}, {3}, {4}, {5}, {6},{7},{8},{9},{10}),",
                            t.ExamID, t.LessionID.NullNumber(), t.TeacherID.NullNumber(), t.StudentID.NullNumber(), t.TestID.NullNumber(), t.StemID.NullNumber(), t.Answer.NullString(), t.AnswerResID.NullNumber(), t.AnswerResUrl.NullString(), t.IsCorrect ? 1 : 0, t.AnswerTime.NullDate());
                    });
                }
                return new Tuple<string, string>(sb.ToString(), _ids);
            };
        }

        new public static void SaveEntity(Model.ReExamDetail t)
        {
            SyncBase<Model.ReExamDetail>.SaveEntity(t);
        }

        new public static void AsyncData()
        {
            SyncBase<Model.ReExamDetail>.AsyncData();
        }
    }
}
